//
//  DesignerGoodsCell.m
//  ForestPack
//
//  Created by jimmy on 2018/7/23.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "DesignerGoodsCell.h"
#import "Masonry.h"

@implementation DesignerGoodsCell

+(DesignerGoodsCell *)cellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath rightBtnTitle:(NSString *)title
{
    static NSString *cellID = @"DesignerGoodsCell";
    DesignerGoodsCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[DesignerGoodsCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        [cell creatViewUIWithRightBtnTitle:title];
    }
    return cell;
    
}

-(void)contactClicked
{
    
}

-(void)sureClick
{
    
}

-(void)notSureClick
{
    
}

-(void)seeDetail
{
    
}

-(void)creatViewUIWithRightBtnTitle:(NSString *)title
{
    UIImageView * headImageV = [[UIImageView alloc] init];
    headImageV.image = [UIImage imageNamed:@"头部背景"];
    headImageV.layer.masksToBounds = YES;
    headImageV.layer.cornerRadius = 24;
    [self addSubview:headImageV];
    [headImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(13);
        make.top.equalTo(self.mas_top).offset(10);
        make.width.equalTo(@48);
        make.height.equalTo(@48);
    }];
    
    UILabel *nameLabel = [[UILabel alloc] init];
    nameLabel.text = @"昵称";
    nameLabel.textColor = FONTCOLOR_BLACK;
    nameLabel.textAlignment = NSTextAlignmentLeft;
    nameLabel.font = Kfont(14);
    [self addSubview:nameLabel];
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(headImageV.mas_right).offset(5);
        make.top.equalTo(self.mas_top).offset(15);
        make.width.equalTo(@40);
        make.height.equalTo(@20);
    }];
    
    self.contactBtn = [[UIButton alloc] init];
    [self.contactBtn setBackgroundImage:[UIImage imageNamed:@"发消息2"] forState:UIControlStateNormal];
    [self.contactBtn addTarget:self action:@selector(contactClicked) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.contactBtn];
    [self.contactBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(nameLabel.mas_right).offset(10);
        make.top.equalTo(self.mas_top).offset(15);
        make.width.equalTo(@22);
        make.height.equalTo(@22);
    }];
    
    UILabel *nickLabel = [[UILabel alloc] init];
    nickLabel.text = @"我是谁谁谁";
    nickLabel.textColor = RGB_COLOR(153, 153, 153);
    nickLabel.textAlignment = NSTextAlignmentLeft;
    nickLabel.font = Kfont(12);
    [self addSubview:nickLabel];
    [nickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(headImageV.mas_right).offset(5);
        make.top.equalTo(nameLabel.mas_bottom).offset(5);
        make.width.equalTo(@(SCREEN_WIDTH - 173));
        make.height.equalTo(@20);
    }];
    
    UIButton *sureBtn = [[UIButton alloc] init];
    [sureBtn setTitle:title forState:UIControlStateNormal];
    sureBtn.titleLabel.font = Kfont(14);
    sureBtn.layer.masksToBounds = YES;
    sureBtn.layer.cornerRadius = 15;
    [sureBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    sureBtn.backgroundColor = RGB_COLOR(237,34,59);
    [sureBtn addTarget:self action:@selector(sureClick) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:sureBtn];
    [sureBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).offset(-13);
        make.top.equalTo(self.mas_top).offset(20);
        make.width.equalTo(@94);
        make.height.equalTo(@30);
    }];
    
    UILabel *contentLabel = [[UILabel alloc] init];
    contentLabel.text = @"contentLabelcontentLabelcontentLabel";
    contentLabel.textColor = FONTCOLOR_BLACK;
    contentLabel.numberOfLines = 0;
    contentLabel.textAlignment = NSTextAlignmentLeft;
    contentLabel.font = Kfont(12);
    [self addSubview:contentLabel];
    [contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(13);
        make.top.equalTo(headImageV.mas_bottom).offset(10);
        make.width.equalTo(@(SCREEN_WIDTH - 100));
        make.height.equalTo(@30);
    }];
    
    UIButton *detailBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [detailBtn setTitle:@"查看详情" forState:UIControlStateNormal];
    detailBtn.titleLabel.font = Kfont(12);
    [detailBtn setTitleColor:RGB_COLOR(237,34,59) forState:UIControlStateNormal];
    [detailBtn addTarget:self action:@selector(seeDetail) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:detailBtn];
    [detailBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).offset(-13);
        make.top.equalTo(sureBtn.mas_bottom).offset(10);
        make.width.equalTo(@74);
        make.height.equalTo(@15);
    }];
    
    for (int i = 0; i < 3; i ++) {
        UIImageView * contentImageV = [[UIImageView alloc] init];
        contentImageV.image = [UIImage imageNamed:@"头部背景"];
        [self addSubview:contentImageV];
        [contentImageV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@(13 * (i + 1) + i * 103));
            make.top.equalTo(contentLabel.mas_bottom).offset(5);
            make.width.equalTo(@((SCREEN_WIDTH - 52)/3));
            make.height.equalTo(@71);
        }];
    }
    
    self.moneyLabel = [[UILabel alloc] init];
    self.moneyLabel.text = @"议价金额：2000.00元";
    self.moneyLabel.textColor = RGB_COLOR(237,34,59);
    self.moneyLabel.textAlignment = NSTextAlignmentCenter;
    self.moneyLabel.font = Kfont(12);
    [self addSubview:self.moneyLabel];
    [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(50);
        make.top.equalTo(detailBtn.mas_bottom).offset(116);
        make.width.equalTo(@(SCREEN_WIDTH - 100));
        make.height.equalTo(@20);
    }];
    
    //这里的同意不同意议价，应该是中标的设计师那里选择的，然后传进来，判断按钮的状态
    //目前 同意的按钮是灰色的，不同意的按钮是红色的
    self.yesBtn = [[UIButton alloc] init];
    self.yesBtn.layer.masksToBounds = YES;
    self.yesBtn.layer.cornerRadius = 22;
    [self.yesBtn setTitleColor:RGB_COLOR(194,194,194) forState:UIControlStateNormal];
    self.yesBtn.backgroundColor = RGB_COLOR(238,238,238);
    [self.yesBtn setTitle:@"同意议价" forState:UIControlStateNormal];
    [self.yesBtn addTarget:self action:@selector(sureClick) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.yesBtn];
    [self.yesBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(13);
        make.top.equalTo(self.moneyLabel.mas_bottom).offset(60);
        make.width.equalTo(@(SCREEN_WIDTH - 26));
        make.height.equalTo(@44);
    }];
    
    self.noBtn = [[UIButton alloc] init];
    self.noBtn.layer.masksToBounds = YES;
    self.noBtn.layer.cornerRadius = 22;
    [self.noBtn setTitle:@"不同意议价" forState:UIControlStateNormal];
    [self.noBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.noBtn.backgroundColor = RGB_COLOR(237,34,59);
    [self.noBtn addTarget:self action:@selector(notSureClick) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.noBtn];
    [self.noBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(13);
        make.top.equalTo(self.yesBtn.mas_bottom).offset(15);
        make.width.equalTo(@(SCREEN_WIDTH - 26));
        make.height.equalTo(@44);
    }];
}

@end
